package com.company;

public class Test24冒泡排序 {
    public static void main(String[] args) {
        int num[]={1,9,5,3,9,6,8,20,4};
        maopao(num);
    }

    /**
     * 冒泡排序
     * @param num
     */
    public static void maopao(int num[]){
        int tmp=0;
        for(int i=0;i<num.length-1;i++){
            for(int j=0;j<num.length-i-1;j++){
                if(num[j]>num[j+1]){
                    tmp=num[j];
                    num[j]=num[j+1];
                    num[j+1]=tmp;
                }
            }
        }
        for(int i=0;i<num.length;i++){
            System.out.println(num[i]);
        }
    }
}
